{% extends 'base.html' %}

{% block content %}
    <script>
    document.addEventListener("DOMContentLoaded",function(evt) {
        document.getElementById("li-m-" + {{ sticky_paper.id }}).style.background = 'wheat'
        }
    )
</script>
    <p>{{ sticky_paper|length }} Titles</p>
    <h3>{{ user.name }} 正在编辑条目：</h3>
    <form method="post" action="{{ url_for('update', sticky_paper_id=sticky_paper.id) }}">
        <label for="edit-title">电影名：</label>
        <input id="edit-title" type="text" name="title" value="{{ sticky_paper.title }}" placeholder="请输入电影名称"
               autocomplete="off" required>
        <label for="edit-year">上映年代：</label>
        <input id="edit-year" type="text" name="year" value="{{ sticky_paper.year }}" placeholder="输入年代" autocomplete="off"
               required>
        <input class="btn" type="submit" name="submit" value="提交">
    </form>
    <ul class="movie-list">
        {% for sticky_paper in sticky_papers %} {# 迭代movies变量 #}
        <li id="li-m-{{ sticky_paper.id }}">{{ sticky_paper.title }} - {{ sticky_paper.year }}
            <!--添加删除按钮-->
            <span class="float-right">
                <!--添加IMDB链接-->
                <a class="imdb" href="https://www.imdb.com/find?q={{ movie.title }}" target="_blank"
                   title="Find this movie on IMDB">IMDB
                </a>
            </span>
            <form class="inline-form" method="post" action="{{ url_for('delete', sticky_paper=sticky_paper.id) }}">
                <input class="btn" type="submit" name="delete" value="Delete" onclick="return confirm('Are You Sure?')">
            </form>
            <form class="inline-form" method="post" action="{{ url_for('edit', sticky_paper=sticky_paper.id) }}">
                <input class="btn" type="submit" name="edit" value="edit">
            </form>
        </li> {# 等同于movie['title'] #}
        {% endfor %}
    </ul>
{% endblock %}